Iniciativa = NA,
military_advantage = NA)
##############################################################################
omc_cmi <- omc_cmi %>%
mutate(del_ga1 = case_when(
GrupoArmado1 == "AGENTE EXTRANJERO" | GrupoArmado1 == "BANDOLERISMO" |
GrupoArmado1 == "CRIMEN ORGANIZADO"
| GrupoArmado1 == "GRUPO POSDESMOVILIZACIÓN" ~ "Other Group",
GrupoArmado1 == "GRUPO ARMADO NO DIRIMIDO" | GrupoArmado1 == "GRUPO ARMADO NO IDENTIFICADO" ~ "Unidentified Group",
GrupoArmado1 == "DESCONOCIDO" | GrupoArmado1 == "OTRO ¿CUÁL?" ~ "Unknown",
TRUE ~ "Exclude")) # Double check the purpose of 'Exclude'
omc_cmi %>%
group_by(GrupoArmado1) %>%
count()
omc_cmi <- omc_cmi %>%
mutate(state_forces = case_when(
GrupoArmado1 == "AGENTE DEL ESTADO" |
GrupoArmado1 == "AGENTE DEL ESTADO - GRUPO PARAMILITAR" |
GrupoArmado1 == "AGENTE DEL ESTADO - GRUPO POSDESMOVILIZACIÓN"
~ 1,
TRUE ~ 0))
omc_cmi <- omc_cmi %>%
mutate(rebel_groups = case_when(
GrupoArmado1 == "GUERRILLA" ~ 1,
TRUE ~ 0))
omc_cmi <- omc_cmi %>%
mutate(progov_militias = case_when(
GrupoArmado1 == "GRUPO PARAMILITAR" |
GrupoArmado1 == "AGENTE DEL ESTADO - GRUPO PARAMILITAR"  ~ 1,
TRUE ~ 0))
omc_cmi <- omc_cmi %>%
mutate(other_ag = case_when(
del_ga1 == "Other Group" ~ 1,
TRUE ~ 0))
omc_cmi <- omc_cmi %>%
mutate(unident_ag = case_when(
del_ga1 == "Unidentified Group" ~ 1,
TRUE ~ 0))
omc_cmi <- omc_cmi %>%
mutate(unknown = case_when(
del_ga1 == "Unknown" ~ 1,
TRUE ~ 0))
omc_cmi <- omc_cmi %>%
select(id_event, id_related_case, year, month, day,
divipola_alt, mun_uc, dep_uc,
target, event_type,
clash, clash_2, air_attack, mil_operation, tatt_mil_target, ambush, hitnrun, raid,
assassination, massacre, f_disapp, ind_kidn, col_kidn, sex_v, attack_civp, tatt_civ_target,
map_muse, tatt_amb_target,
state_forces, rebel_groups, progov_militias, other_ag, unident_ag, unknown,
captured_nonstate, captured_name_group,
deaths_military, deaths_police, deaths_other_state, deaths_unknown_state,
deaths_state_forces, deaths_rebels, deaths_pgm, deaths_gpdp,
deaths_unknown_groups, deaths_other_groups, deaths_nonstate_groups,
deaths_total_combatants, deaths_total_noinfo, deaths_total_civilians,
GrupoArmado1, GrupoArmado1_name, GrupoArmado2, GrupoArmado2_name, GrupoArmado3, GrupoArmado3_name,
Iniciativa, military_advantage)
omc_cat_aobj <- omc_cat_aobj %>%
select(id_event, id_related_case, year, month, day,
divipola_alt, mun_uc, dep_uc,
target, event_type,
clash, clash_2, air_attack, mil_operation, tatt_mil_target, ambush, hitnrun, raid,
assassination, massacre, f_disapp, ind_kidn, col_kidn, sex_v, attack_civp, tatt_civ_target,
map_muse, tatt_amb_target,
state_forces, rebel_groups, progov_militias, other_ag, unident_ag, unknown,
captured_nonstate, captured_name_group,
deaths_military, deaths_police, deaths_other_state, deaths_unknown_state,
deaths_state_forces, deaths_rebels, deaths_pgm, deaths_gpdp,
deaths_unknown_groups, deaths_other_groups, deaths_nonstate_groups,
deaths_total_combatants, deaths_total_noinfo, deaths_total_civilians,
GrupoArmado1, GrupoArmado1_name, GrupoArmado2, GrupoArmado2_name, GrupoArmado3, GrupoArmado3_name,
Iniciativa, military_advantage, Modalidad)
omc_cat_aobj <- omc_cat_aobj %>%
select(id_event, id_related_case, year, month, day,
divipola_alt, mun_uc, dep_uc,
target, event_type,
clash, clash_2, air_attack, mil_operation, tatt_mil_target, ambush, hitnrun, raid,
assassination, massacre, f_disapp, ind_kidn, col_kidn, sex_v, attack_civp, tatt_civ_target,
map_muse, tatt_amb_target,
state_forces, rebel_groups, progov_militias, other_ag, unident_ag, unknown,
captured_nonstate, captured_name_group,
deaths_military, deaths_police, deaths_other_state, deaths_unknown_state,
deaths_state_forces, deaths_rebels, deaths_pgm, deaths_gpdp,
deaths_unknown_groups, deaths_other_groups, deaths_nonstate_groups,
deaths_total_combatants, deaths_total_noinfo, deaths_total_civilians,
GrupoArmado1, GrupoArmado1_name, GrupoArmado2, GrupoArmado2_name, GrupoArmado3, GrupoArmado3_name,
Iniciativa, military_advantage)
omc_aco <- dplyr::bind_rows(omc_cmi, omc_cat_aobj)
str(omc_cco)
omc_aco_dep <- omc_aco %>% distinct(id_event, year, month, day, divipola_alt, .keep_all = TRUE)
write_csv(omc_aco, "~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)_OMC-CasosFinal_AmbiguousTarget-Updated(09132024).csv")
omc_cmt <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)_OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
library(tidyverse)
library(readstata13)
library(foreign)
library(readxl)
library(writexl)
omc_cmt <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)_OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
omc_cmt <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)_OMC-CasosFinal_AmbiguousTarget-Updated(09132024).csv")
omc_cct <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)_OMC-CasosFinal_CivilianTarget-Updated(09132024).csv")
omc_cat <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)_OMC-CasosFinal_AmbiguousTarget-Updated(09132024).csv")
omc_cmt <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
omc_cf <- dplyr::bind_rows(omc_cmt, omc_cct)
omc_cf <- dplyr::bind_rows(omc_cf, omc_cat)
rm(omc)cf
rm(omc_cf)
omc_cmt <- omc_cmt %>%
select(id_event, id_related_case, year, month, day,
divipola_alt, mun_uc, dep_uc,
target, event_type,
clash, clash_2, air_attack, mil_operation, tatt_mil_target, ambush, hitnrun, raid,
assassination, massacre, f_disapp, ind_kidn, col_kidn, sex_v, attack_civp, tatt_civ_target,
map_muse, tatt_amb_target,
state_forces, rebel_groups, progov_militias, other_ag, unident_ag, unknown,
captured_nonstate, captured_name_group,
deaths_military, deaths_police, deaths_other_state, deaths_unknown_state,
deaths_state_forces, deaths_rebels, deaths_pgm, deaths_gpdp,
deaths_unknown_groups, deaths_other_groups, deaths_nonstate_groups,
deaths_total_combatants, deaths_total_noinfo, deaths_total_civilians,
GrupoArmado1, GrupoArmado1_name, GrupoArmado2, GrupoArmado2_name, GrupoArmado3, GrupoArmado3_name,
Iniciativa)
str(omc_cct)
omc_cmt <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
omc_cmt <- omc_cmt %>%
select(id_event, id_related_case, year, month, day,
divipola_alt, mun_uc, dep_uc,
target, event_type,
clash, clash_2, air_attack, mil_operation, tatt_mil_target, ambush, hitnrun, raid,
assassination, massacre, f_disapp, ind_kidn, col_kidn, sex_v, attack_civp, tatt_civ_target,
map_muse, tatt_amb_target,
state_forces, rebel_groups, progov_militias, other_ag, unident_ag, unknown,
captured_nonstate, captured_name_group,
deaths_military, deaths_police, deaths_other_state, deaths_unknown_state,
deaths_state_forces, deaths_rebels, deaths_pgm, deaths_gpdp,
deaths_unknown_groups, deaths_other_groups, deaths_nonstate_groups,
deaths_total_combatants, deaths_total_noinfo, deaths_total_civilians,
GrupoArmado1, GrupoArmado1_name, GrupoArmado2, GrupoArmado2_name, GrupoArmado3, GrupoArmado3_name,
Iniciativa, military_advantage)
omc_cct <- omc_cct %>%
select(-Modalidad)
omc_cf <- dplyr::bind_rows(omc_cmt, omc_cct)
omc_cf <- dplyr::bind_rows(omc_cf, omc_cat)
omc_cf <- omc_cf %>%
dplyr::filter(year != 0)
omc_cf <- omc_cf %>%
dplyr::filter(divipola_alt != "00000")
omc_cf <- omc_cf %>%
dplyr::filter(divipola_alt != "0")
str(omc_cf)
write_csv(omc_cf, "~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project3/RegionalData/OMC-Data_Updated-Products(2024)/Ortega(2024)-OMC-CasosFinal_Aggregated(09142024).csv")
omc <- read_csv("Ortega(2024)-OMC-CasosFinal_Aggregated(09022021).csv")
rm(omc, omc_cat)
omc <- read_csv("Ortega(2024)-OMC-CasosFinal_Aggregated(09142024).csv")
rm(omc_cf)
View(omc)
omc_tscs_t <- omc %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(conf_events = n(),
clashes = sum(clash),
clashes_2 = sum(clash_2),
air_attacks = sum(air_attack),
mil_operations = sum(mil_operation),
tatt_mil_targets = sum(tatt_mil_target),
ambushes = sum(ambush),
hitnruns = sum(hitnrun),
raids = sum(raid),
assassinations = sum(assassination),
massacres = sum(massacre),
f_disapps = sum(f_disapp),
ind_kidns = sum(ind_kidn),
col_kidns = sum(col_kidn),
sex_vs = sum(sex_v),
attack_civps = sum(attack_civp),
tatt_civ_targets = sum(tatt_civ_target),
map_muses = sum(map_muse),
tatt_amb_targets = sum(tatt_amb_target),
unil_actions = air_attacks + mil_operations
+ tatt_mil_targets + ambushes + hitnruns + raids
+ assassinations + massacres + f_disapps + ind_kidns
+ col_kidns + sex_vs + attack_civps + tatt_civ_targets
+ map_muses + tatt_amb_targets)
View(omc_tscs_t)
#################################################################
omc_tscs_t %>% # Check that UA are not greater than CE
group_by(year) %>%
mutate(check = conf_events - unil_actions,
log_st = case_when(
check < 0 ~ "Review"))
#################################################################
x <- omc_tscs_t %>% # Check that UA are not greater than CE
group_by(year) %>%
mutate(check = conf_events - unil_actions,
log_st = case_when(
check < 0 ~ "Review"))
x %>%
group_by(check) %>%
count()
write_csv(x, "Check&Delete.csv")
omc_tscs_t_mt <- omc %>%
filter(target == "1. Military") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(conf_events_mt = n())
View(omc_tscs_t_mt)
omc_tscs_t_ct <- omc %>%
filter(target == "2. Civilian") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(conf_events_ct = n())
View(omc_tscs_t_ct)
omc_tscs_tf <- left_join(omc_tscs_t, omc_tscs_t_mt)
omc_tscs_tf <- left_join(omc_tscs_tf, omc_tscs_t_ct)
omc_tscs_tf <- omc_tscs_tf %>%
relocate(divipola_alt, mun_uc, year, conf_events, conf_events_mt, conf_events_ct,
clashes, clashes_2, unil_actions)
View(omc_tscs_tf)
View(omc)
omc_tscs_sf <- omc %>%
filter(state_forces == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(sf_conf_events = n(),
sf_clashes = sum(clash),
sf_clashes_2 = sum(clash_2),
sf_air_attacks = sum(air_attack),
sf_mil_operations = sum(mil_operation),
sf_tatt_mil_targets = sum(tatt_mil_target),
sf_ambushes = sum(ambush),
sf_hitnruns = sum(hitnrun),
sf_raids = sum(raid),
sf_assassinations = sum(assassination),
sf_massacres = sum(massacre),
sf_f_disapps = sum(f_disapp),
sf_ind_kidns = sum(ind_kidn),
sf_col_kidns = sum(col_kidn),
sf_sex_vs = sum(sex_v),
sf_attack_civps = sum(attack_civp),
sf_tatt_civ_targets = sum(tatt_civ_target),
sf_map_muses = sum(map_muse),
sf_tatt_amb_targets = sum(tatt_amb_target),
sf_unil_actions = sf_air_attacks + sf_mil_operations
+ sf_tatt_mil_targets + sf_ambushes + sf_hitnruns + sf_raids
+ sf_assassinations + sf_massacres + sf_f_disapps + sf_ind_kidns
+ sf_col_kidns + sf_sex_vs + sf_attack_civps + sf_tatt_civ_targets
+ sf_map_muses + sf_tatt_amb_targets)
View(omc_tscs_sf)
rm(omc_tscs_sf)
omc_tscs_sf <- omc %>%
filter(state_forces == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(sf_conf_events = n(),
sf_clashes = sum(clash),
sf_clashes_2 = sum(clash_2),
sf_air_attacks = sum(air_attack),
sf_mil_operations = sum(mil_operation),
sf_ambushes = sum(ambush),
sf_hitnruns = sum(hitnrun),
sf_raids = sum(raid),
sf_assassinations = sum(assassination),
sf_massacres = sum(massacre),
sf_f_disapps = sum(f_disapp),
sf_ind_kidns = sum(ind_kidn),
sf_col_kidns = sum(col_kidn),
sf_sex_vs = sum(sex_v),
sf_attack_civps = sum(attack_civp),
sf_map_muses = sum(map_muse),
sf_unil_actions = sf_air_attacks + sf_mil_operations
+ sf_ambushes + sf_hitnruns + sf_raids
+ sf_assassinations + sf_massacres + sf_f_disapps + sf_ind_kidns
+ sf_col_kidns + sf_sex_vs + sf_attack_civps
+ sf_map_muses)
View(omc_tscs_sf)
omc_tscs_sf_mt <- omc %>%
filter(state_forces == 1) %>%
filter(target == "1. Military") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(sf_conf_events_mt = n())
omc_tscs_sf_ct <- omc %>%
filter(state_forces == 1) %>%
filter(target == "2. Civilian") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(sf_conf_events_ct = n())
omc_tscs_sf_f <- left_join(omc_tscs_sf, omc_tscs_sf_mt)
omc_tscs_sf_f <- left_join(omc_tscs_sf_f, omc_tscs_sf_ct)
omc_tscs_sf_f <- omc_tscs_sf_f %>%
relocate(divipola_alt, mun_uc, year, sf_conf_events, sf_conf_events_mt,
sf_conf_events_ct, sf_clashes, sf_unil_actions)
View(omc_tscs_sf_f)
omc_tscs_rg <- omc %>%
filter(rebel_groups == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(rg_conf_events = n(),
rg_clashes = sum(clash),
rg_air_attacks = sum(air_attack),
rg_mil_operations = sum(mil_operation),
rg_tatt_mil_targets = sum(tatt_mil_target),
rg_ambushes = sum(ambush),
rg_hitnruns = sum(hitnrun),
rg_raids = sum(raid),
rg_assassinations = sum(assassination),
rg_massacres = sum(massacre),
rg_f_disapps = sum(f_disapp),
rg_ind_kidns = sum(ind_kidn),
rg_col_kidns = sum(col_kidn),
rg_sex_vs = sum(sex_v),
rg_attack_civps = sum(attack_civp),
rg_map_muses = sum(map_muse),
rg_unil_actions = rg_air_attacks + rg_mil_operations
+ rg_tatt_mil_targets + rg_ambushes + rg_hitnruns + rg_raids
+ rg_assassinations + rg_massacres + rg_f_disapps + rg_ind_kidns
+ rg_col_kidns + rg_sex_vs + rg_attack_civps + rg_map_muses)
View(omc_tscs_rg)
rm(omc_tscs_rg)
omc_tscs_rg <- omc %>%
filter(rebel_groups == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(rg_conf_events = n(),
rg_clashes = sum(clash),
rg_tatt_mil_targets = sum(tatt_mil_target),
rg_ambushes = sum(ambush),
rg_hitnruns = sum(hitnrun),
rg_raids = sum(raid),
rg_assassinations = sum(assassination),
rg_massacres = sum(massacre),
rg_f_disapps = sum(f_disapp),
rg_ind_kidns = sum(ind_kidn),
rg_col_kidns = sum(col_kidn),
rg_sex_vs = sum(sex_v),
rg_attack_civps = sum(attack_civp),
rg_tatt_civ_targets = sum(tatt_civ_target),
rg_map_muses = sum(map_muse),
rg_tatt_amb_targets = sum(tatt_amb_target),
rg_unil_actions = rg_tatt_mil_targets + rg_ambushes + rg_hitnruns + rg_raids
+ rg_assassinations + rg_massacres + rg_f_disapps + rg_ind_kidns
+ rg_col_kidns + rg_sex_vs + rg_attack_civps + rg_tatt_civ_targets
+ rg_map_muses + rg_tatt_amb_targets)
View(omc_tscs_rg)
omc_tscs_rg <- omc %>%
filter(rebel_groups == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(rg_conf_events = n(),
rg_clashes = sum(clash),
rg_clashes_2 = sum(clash_2),
rg_tatt_mil_targets = sum(tatt_mil_target),
rg_ambushes = sum(ambush),
rg_hitnruns = sum(hitnrun),
rg_raids = sum(raid),
rg_assassinations = sum(assassination),
rg_massacres = sum(massacre),
rg_f_disapps = sum(f_disapp),
rg_ind_kidns = sum(ind_kidn),
rg_col_kidns = sum(col_kidn),
rg_sex_vs = sum(sex_v),
rg_attack_civps = sum(attack_civp),
rg_tatt_civ_targets = sum(tatt_civ_target),
rg_map_muses = sum(map_muse),
rg_tatt_amb_targets = sum(tatt_amb_target),
rg_unil_actions = rg_tatt_mil_targets + rg_ambushes + rg_hitnruns + rg_raids
+ rg_assassinations + rg_massacres + rg_f_disapps + rg_ind_kidns
+ rg_col_kidns + rg_sex_vs + rg_attack_civps + rg_tatt_civ_targets
+ rg_map_muses + rg_tatt_amb_targets)
View(omc_tscs_rg)
omc_tscs_rg_mt <- omc %>%
filter(rebel_groups == 1) %>%
filter(target == "1. Military") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(rg_conf_events_mt = n())
omc_tscs_rg_ct <- omc %>%
filter(rebel_groups == 1) %>%
filter(target == "2. Civilian") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(rg_conf_events_ct = n())
omc_tscs_rg_f <- left_join(omc_tscs_rg, omc_tscs_rg_mt)
omc_tscs_rg_f <- left_join(omc_tscs_rg_f, omc_tscs_rg_ct)
omc_tscs_rg_f <- omc_tscs_rg_f %>%
relocate(divipola_alt, mun_uc, year, rg_conf_events, rg_conf_events_mt,
rg_conf_events_ct, rg_clashes, rg_unil_actions)
View(omc_tscs_rg_f)
omc_tscs_pm <- omc %>%
filter(progov_militias == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(pm_conf_events = n(),
pm_clashes = sum(clash),
pm_clashes_2 = sum(clash_2),
pm_tatt_mil_targets = sum(tatt_mil_target),
pm_ambushes = sum(ambush),
pm_hitnruns = sum(hitnrun),
pm_raids = sum(raid),
pm_assassinations = sum(assassination),
pm_massacres = sum(massacre),
pm_f_disapps = sum(f_disapp),
pm_ind_kidns = sum(ind_kidn),
pm_col_kidns = sum(col_kidn),
pm_sex_vs = sum(sex_v),
pm_attack_civps = sum(attack_civp),
pm_tatt_civ_targets = sum(tatt_civ_target),
pm_map_muses = sum(map_muse),
pm_tatt_amb_targets = sum(tatt_amb_target),
pm_unil_actions = pm_tatt_mil_targets + pm_ambushes + pm_hitnruns + pm_raids
+ pm_assassinations + pm_massacres + pm_f_disapps + pm_ind_kidns
+ pm_col_kidns + pm_sex_vs + pm_attack_civps + pm_tatt_civ_targets
+ pm_map_muses + pm_tatt_amb_targets)
View(omc_tscs_pm)
omc_tscs_pm_mt <- omc %>%
filter(progov_militias == 1) %>%
filter(target == "1. Military") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(pm_conf_events_mt = n())
omc_tscs_pm_ct <- omc %>%
filter(progov_militias == 1) %>%
filter(target == "2. Civilian") %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(pm_conf_events_ct = n())
omc_tscs_pm_f <- left_join(omc_tscs_pm, omc_tscs_pm_mt)
omc_tscs_pm_f <- left_join(omc_tscs_pm_f, omc_tscs_pm_ct)
omc_tscs_pm_f <- omc_tscs_pm_f %>%
relocate(divipola_alt, mun_uc, year, pm_conf_events, pm_conf_events_mt,
pm_conf_events_ct, pm_clashes, pm_unil_actions)
View(omc_tscs_pm_f)
omc_tscs_cl_sfrg <- omc %>%
filter(state_forces == 1 & rebel_groups == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_st_rg_1 = sum(clash))
omc_tscs_cl_sfrg2 <- omc %>%
filter(state_forces == 1 & rebel_groups == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_st_rg_2 = sum(clash_2))
View(omc_tscs_cl_sfrg)
View(omc_tscs_cl_sfrg2)
View(omc)
View(omc_tscs_cl_sfrg)
View(omc_tscs_cl_sfrg2)
all.equal(omc_tscs_cl_sfrg$cl_st_rg_1, omc_tscs_cl_sfrg2$cl_st_rg_2)
summarise(omc_tscs_cl_sfrg$cl_st_rg_1)
summarise(omc_tscs_cl_sfrg$cl_st_rg_1)
str(omc_tscs_cl_sfrg)
str(omc)
all.equal(omc$clash, omc$clash_2)
all.equal(omc_tscs_cl_sfrg$cl_st_rg_1, omc_tscs_cl_sfrg2$cl_st_rg_2)
omc_tscs_cl_sfrg <- omc %>%
filter(state_forces == 1 & rebel_groups == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_st_rg_1 = sum(clash),
cl_st_rg_2 = sum(clash_2))
View(omc_tscs_cl_sfrg)
omc_tscs_cl_rgpm <- omc %>%
filter(rebel_groups == 1 & progov_militias == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_rg_pm_1 = sum(clash))
View(omc_tscs_cl_rgpm)
omc_tscs_cl_rgpm <- omc %>%
filter(rebel_groups == 1 & progov_militias == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_rg_pm_1.1 = sum(clash),
cl_rg_pm_1.2 = sum(clash_2))
View(omc_tscs_cl_rgpm)
omc_tscs_cl_rgpm_alt <- omc %>%
filter(rebel_groups == 1 & progov_militias == 1 & state_forces == 0) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_rg_pm_2.1 = sum(clash),
cl_rg_pm_2.2 = sum(clash_2)) # I think this is better because it excludes the cases in which the participates.
View(omc_tscs_cl_rgpm_alt)
omc_tscs_ff <- left_join(omc_tscs_tf, omc_tscs_sf_f)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_rg_f)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_pm_f)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_cl_sfrg)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_cl_rgpm)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_cl_rgpm_alt)
omc_tscs_ff <- omc_tscs_ff %>% replace(is.na(.), 0) # It is correct because the NAs are created for the aggregation of data.
View(omc_tscs_ff)
rm(omc_tscs_ff)
rm(omc_tscs_cl_rgpm)
rm(omc_tscs_cl_rgpm_alt)
omc_tscs_cl_rgpm <- omc %>%
filter(rebel_groups == 1 & progov_militias == 1) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_rg_pm_1a = sum(clash),
cl_rg_pm_2a = sum(clash_2))
View(omc_tscs_cl_rgpm)
omc_tscs_cl_rgpm_alt <- omc %>%
filter(rebel_groups == 1 & progov_militias == 1 & state_forces == 0) %>%
group_by(year, divipola_alt, mun_uc) %>%
summarise(cl_rg_pm_1b = sum(clash),
cl_rg_pm_2b = sum(clash_2)) # I think this is better because it excludes the cases in which the participates.
View(omc_tscs_cl_sfrg2)
View(omc_tscs_cl_rgpm_alt)
omc_tscs_ff <- left_join(omc_tscs_tf, omc_tscs_sf_f)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_rg_f)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_pm_f)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_cl_sfrg)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_cl_rgpm)
omc_tscs_ff <- left_join(omc_tscs_ff, omc_tscs_cl_rgpm_alt)
omc_tscs_ff <- omc_tscs_ff %>% replace(is.na(.), 0) # It is correct because the NAs are created for the aggregation of data.
write_csv(omc_tscs_ff, "Ortega(2024)-OMC-TSCS_CasosFinal-Updated(09142024).csv")
omc2 <- read_csv("Ortega(2024)-OMC-TSCS_CasosFinal(12012021).csv")
str(omc2)
View(omc2)
View(omc_tscs_ff)
omc_mt <- read_csv("Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
omc_mt <- read_csv("Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
omc_cmt <- write_csv("Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
View(omc_cmt)
rm(omc_cmt, omc_cct)
omc_cmt <- write_csv("Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
omc_cmt <- write_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project1/Replication/5.Data/CV/OMC-PreProcessing-Updated/Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
omc_cmt <- write_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project1/Replication/5.Data/CV/OMC-PreProcessing-Updated/Ortega(2024)-OMC-CasosFinal_MilitaryTarget-Updated(09132024).csv")
is.data.frame(omc_cmt)
omc_cmt <- write_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project1/Replication/5.Data/CV/OMC-PreProcessing-Updated/Ortega(2024)_OMC-CasosFinal_CivilianTarget-Updated(09132024).csv")
write_xlsx(omc_tscs_ff, "Ortega(2024)-OMC-TSCS_CasosFinal-Updated(09142024).xlsx")
save.dta13(omc_tscs_ff, file="Ortega(2024)-OMC-TSCS_CasosFinal-Updated(09142024).dta")
save.dta13(omc_tscs_ff, "Ortega(2024)-OMC-TSCS_CasosFinal-Updated(09142024).dta")
library(readstata13)
save.dta13(omc_tscs_ff, "Ortega(2024)-OMC-TSCS_CasosFinal-Updated(09142024).dta")
save.dta13(omc_tscs_ff, file="Ortega(2024)-OMC-TSCS_CasosFinal-Updated(09142024).dta")
readstata13::save.dta13(omc_tscs_ff, "Ortega(2024)-OMC-TSCS_CasosFinal-Updated(09142024).dta")
